//
//  calculaterViewController.m
//  calculater
//
//  Created by 1 on 11-9-1.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "calculaterViewController.h"

@implementation calculaterViewController
@synthesize showText;
@synthesize showSave;

- (IBAction) clear{
	opSign = 0;
    output = 0 ;
    showText.text = [NSString stringWithFormat:@"0"];
}
- (IBAction) getNumber0
{   
    output = result(0, output);
    showText.text = [NSString stringWithFormat:@""];
    showText.text = [NSString stringWithFormat:@"%@%d",showText.text,output];    
}
- (IBAction) getNumber1
{   
    output = result(1, output);
    showText.text = [NSString stringWithFormat:@""];
    showText.text = [NSString stringWithFormat:@"%@%d",showText.text,output];    
}
- (IBAction) getNumber2
{   
    output = result(2, output);
    showText.text = [NSString stringWithFormat:@""];
    showText.text = [NSString stringWithFormat:@"%@%d",showText.text,output];    
}
- (IBAction) getNumber3
{   
    output = result(3, output);
    showText.text = [NSString stringWithFormat:@""];
    showText.text = [NSString stringWithFormat:@"%@%d",showText.text,output];    
}
- (IBAction) getNumber4
{   
    output = result(4, output);
    showText.text = [NSString stringWithFormat:@""];
    showText.text = [NSString stringWithFormat:@"%@%d",showText.text,output];    
}
- (IBAction) getNumber5
{   
    output = result(5, output);
    showText.text = [NSString stringWithFormat:@""];
    showText.text = [NSString stringWithFormat:@"%@%d",showText.text,output];    
}
- (IBAction) getNumber6
{   
    output = result(6, output);
    showText.text = [NSString stringWithFormat:@""];
    showText.text = [NSString stringWithFormat:@"%@%d",showText.text,output];    
}
- (IBAction) getNumber7
{   
    output = result(7, output);
    showText.text = [NSString stringWithFormat:@""];
    showText.text = [NSString stringWithFormat:@"%@%d",showText.text,output];   
}
- (IBAction) getNumber8
{   
    output = result(8, output);
    showText.text = [NSString stringWithFormat:@""];
    showText.text = [NSString stringWithFormat:@"%@%d",showText.text,output];    
}
- (IBAction) getNumber9
{   
    output = result(9, output);
    showText.text = [NSString stringWithFormat:@""];
    showText.text = [NSString stringWithFormat:@"%@%d",showText.text,output];    
}

- (IBAction) add
{   
    remember1(output);
    opSign = 1;
    output = 0;
    showText.text = [NSString stringWithFormat:@""];
}

- (IBAction) minus
{   
   remember1(output);
    opSign = 2;
    output = 0;
    showText.text = [NSString stringWithFormat:@""];}

- (IBAction) multi
{   
    remember1(output);
    opSign = 3;
    output = 0;
    showText.text = [NSString stringWithFormat:@""];}

- (IBAction) devi
{   
   remember1(output); 
    opSign = 4;
    output = 0;
    showText.text = [NSString stringWithFormat:@""];
}
- (IBAction) equal
{  
    remember2(output);
    output =equalc(opSign);  
    showText.text = [NSString stringWithFormat:@""];
    showText.text = [NSString stringWithFormat:@"%@%d",showText.text,output];  
}
- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
}
*/

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
